import java.util.HashMap;
import java.util.Map;

/**
 * 网站工厂类
 * @author liaosh
 * @date 2022-10-21 17:39
 */
public class WebsiteFacotry {

    /**
     * key：网站分类，value：网站对象
     */
    public Map<String, WebSite> webSiteMap;

    public WebsiteFacotry() {
        webSiteMap = new HashMap<>();
    }

    public WebSite getWebsiteCategory(String websiteCategory) {
        if (!webSiteMap.containsKey(websiteCategory)) {
            // 创建网站并设置到 map 中
            webSiteMap.put(websiteCategory, new ConcreteWebSite(websiteCategory));
        }
        return webSiteMap.get(websiteCategory);
    }

    public Integer getWebsiteCount() {
        return webSiteMap.size();
    }
}
